package com.interagriculture.service.impl;

import com.interagriculture.entity.Dfw;
import com.interagriculture.mapper.DfwMapper;
import com.interagriculture.service.DfwService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class DfwServiceImpl implements DfwService {

    @Autowired
    private DfwMapper dfwMapper;

    /**
     * 获取所有信息
     * @return
     */
    public List<Dfw> getAll() {
        List<Dfw> dfwList = dfwMapper.getAll();
        return dfwList;
    }

    /**
     * 修改或新增
     * @param dfw
     */
    public void saveOrUpdate(Dfw dfw) {
        if(dfw.getId() == null){
            // 新增操作
            dfwMapper.insert(dfw);
        }else{
            // 修改操作
            dfwMapper.update(dfw);
        }
    }

    /**
     * 删除一条信息
     * @param id
     */
    public void delete(Integer id) {
        dfwMapper.deleteById(id);
    }
}
